package com.wenhai.concurrency.thread;

import java.util.concurrent.Callable;
import java.util.concurrent.ExecutionException;
import java.util.concurrent.FutureTask;

/**
 * @ClassName FutureTaskDemo
 * @Description 创建线程方式示例
 * @Author 谢文海
 * @Date 2021/4/8 0:26
 * @Version 1.0
 * @see Thread
 * @see FutureTask
 * @see Callable
 **/
public class FutureTaskDemo {
    public static void main(String[] args) throws ExecutionException, InterruptedException {
        FutureTask<String> futureTask = new FutureTask<>(() -> "Hello, Java  Concurrency");
        new Thread(futureTask).start();
        System.out.println(futureTask.get());
    }
}
